<?php
class RegistrationForm extends Zend_Form
{
    public function init()
    {
        $username = $this->createElement('text','username');
        $username->setLabel('Username: *')
                ->setRequired(true)
                ->addValidator(new Zend_Validate_Db_NoRecordExists('Person', 'username'))
                ->addValidator(new Zend_Validate_StringLength(0, 45));
                
   		$name = $this->createElement('text','name');
        $name->setLabel('Name : *')
				->setRequired(true)
				->addValidator(new Zend_Validate_StringLength(0, 45));
		    
        $tel = $this->createElement('text','tel');
        $tel->setLabel('Phone : ')
        		->addValidator(new Perso_Validate_Phone())
				->setRequired(false)
				->addValidator(new Zend_Validate_StringLength(0, 45));
                    
                    
        $email = $this->createElement('text','email');
        $email->setLabel('Email: *')
                ->setRequired(true)
                ->addValidator(new Zend_Validate_EmailAddress())
                ->addValidator(new Zend_Validate_StringLength(0, 45));
                
        $password = $this->createElement('password','password');
        $password->setLabel('Password: *')
                ->setRequired(true)
                ->addValidator(new Zend_Validate_StringLength(6, 20));
                
        $confirmPassword = $this->createElement('password','confirmPassword');
        $confirmPassword->setLabel('Confirm Password: *')
                ->setRequired(true)
                ->addValidator(new Perso_Validate_ElementConfirmation('password'))
                ->addValidator(new Zend_Validate_StringLength(6, 20));
         
        
 		// Captcha using figlet
		$captcha = new Zend_Form_Element_Captcha('captcha', array(
				    'label' => "Please enter the 6 caracters displayed.",
				    'captcha' => array(
				        'captcha' => 'Figlet',
				        'wordLen' => 6,
				        'timeout' => 300,
				    ),
				));
/*
		// Captcha using ReCaptcha
		// Valid for the domain appweb.labinfo.eiaj.ch
		// Problem : the server doesn't authorize to access web (or proxy config problem)
		$publicKey = '6LegDgoAAAAAAILv9deAw5LGF1pqMlbVD7M5uPvX';
		$privateKey = '6LegDgoAAAAAAA9crEuEB9ybYYv_xSnZRfYJtTc6';
		$recaptcha = new Zend_Service_ReCaptcha($publicKey, $privateKey);
		$captcha = new Zend_Form_Element_Captcha('captcha',
			array('captcha' => 'ReCaptcha',
				'captchaOptions' => array('captcha' => 'ReCaptcha', 
										'service' => $recaptcha)));

*/
         
        $register = $this->createElement('submit','register');
        $register->setLabel('Sign up')
                ->setIgnore(true);
                
        $this->addElements(array(
                        $username,
                        $name,
                        $email,
						$tel,
                        $password,
                        $confirmPassword,
                        $captcha,
                        $register
        ));
    }
}

